﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace MyLibrary.Data.Builder.Config
{
    /// <summary>
    /// 报表条件
    /// </summary>
    [Serializable]
    public class ReportCondition
    {
        private string _cndType = String.Empty;
        /// <summary>
        /// 条件名称
        /// </summary>
        [XmlAttributeAttribute("type")]
        public string ConditionType
        {
            get { return _cndType; }
            set { _cndType = value; }
        }
        private string _cndTitle = String.Empty;
        /// <summary>
        /// 条件标题
        /// </summary>
        [XmlAttributeAttribute("title")]
        public string ConditionTitle
        {
            get { return _cndTitle; }
            set { _cndTitle = value; }
        }

        private string _cndID = String.Empty;
        /// <summary>
        /// 条件ID
        /// </summary>
        [XmlAttributeAttribute("id")]
        public string ConditionID
        {
            get { return _cndID; }
            set { _cndID = value; }
        }
        private string _cndSrc = String.Empty;
        /// <summary>
        /// 条件数据源
        /// </summary>
        [XmlAttributeAttribute("src")]
        public string ConditionSource
        {
            get { return _cndSrc; }
            set { _cndSrc = value; }
        }
        private string _cndContent = String.Empty;
        /// <summary>
        /// 条件内容
        /// </summary>
        [XmlTextAttribute]
        public string ConditionContent
        {
            get { return _cndContent; }
            set { _cndContent = value; }
        }
    }

    /// <summary>
    /// 报表的列标题
    /// </summary>
    [Serializable]
    public class ReportColumn
    {
        private string _colType = String.Empty;
        [XmlAttributeAttribute("type")]
        public string ColumnType
        {
            get { return _colType; }
            set { _colType = value; }
        }
        private string _colContent = String.Empty;
        [XmlTextAttribute]
        public string ColumnContent
        {
            get { return _colContent; }
            set { _colContent = value; }
        }
    }

    /// <summary>
    /// 报表的内容设置
    /// </summary>
    [Serializable]
    public class ReportContent
    {
        private string _assemblyName = String.Empty;
        /// <summary>
        /// 程序集名称
        /// </summary>
        [XmlAttributeAttribute("assembly")]
        public string AssemblyName
        {
            get { return _assemblyName; }
            set { _assemblyName = value; }
        }
        
        private string _nameSpace = String.Empty;
        /// <summary>
        /// 程序集的命名空间
        /// </summary>
        [XmlAttributeAttribute("namespace")]
        public string NameSpace
        {
            get { return _nameSpace; }
            set { _nameSpace = value; }
        }

        private DataSourceList srcList = new DataSourceList();
        /// <summary>
        /// 报表数据源
        /// </summary>
        [XmlElementAttribute("DataSource")]
        public DataSourceList DataSourceList
        {
            get { return srcList; }
            set { srcList = value; }
        }
    }

    /// <summary>
    /// 报表的数据源
    /// </summary>
    [Serializable]
    public class ReportDataSource
    {
        private string _dsType = String.Empty;
        /// <summary>
        /// 数据源类型
        /// </summary>
        [XmlAttributeAttribute("type")]
        public string DatasourceType
        {
            get { return _dsType; }
            set { _dsType = value; }
        }
        private string _dsUrl = String.Empty;
        /// <summary>
        /// URL
        /// </summary>
        [XmlAttributeAttribute("url")]
        public string URL
        {
            get { return _dsUrl; }
            set { _dsUrl = value; }
        }
        private string _dsMethod = String.Empty;
        /// <summary>
        /// 调用的方法名称
        /// </summary>
        [XmlAttributeAttribute("method")]
        public string DatasourceMethod
        {
            get { return _dsMethod; }
            set { _dsMethod = value; }
        }

        private string _defaultParams = String.Empty;
        /// <summary>
        /// 方法的默认参数
        /// </summary>
        [XmlAttributeAttribute("params")]
        public string DefaultParams
        {
            get { return _defaultParams; }
            set { _defaultParams = value; }
        }
    }

    /// <summary>
    /// 报表标签设置
    /// </summary>
    [Serializable]
    public class ReportLabel
    {
        private string _lableName = String.Empty;
        /// <summary>
        /// 标签的名称
        /// </summary>
        [XmlAttributeAttribute("name")]
        public string LableName
        {
            get { return _lableName; }
            set { _lableName = value; }
        }
        private Columns _reportColumns = new Columns();
        /// <summary>
        /// 报表列头集合
        /// </summary>
        [XmlElementAttribute("ColumnsTitle")]
        public Columns ReportColumns
        {
            get { return _reportColumns; }
            set { _reportColumns = value; }
        }
        private ReportContent _reportContent = new ReportContent();
        /// <summary>
        /// 报表内容
        /// </summary>
        [XmlElementAttribute("Content")]
        public ReportContent ReportContent
        {
            get { return _reportContent; }
            set { _reportContent = value; }
        }
    }
}
